package com.zmn.plat.common.dictionary;

/**
 * 渠道接入方式枚举
 *
 * @author linfeng
 * @since 2019 /10/31 14:56:30
 */
public enum ChannelRanKEnum {

    /**
     * values
     */
    FIRST_LEVEL(ChannelRanKEnum.CHANNEL_FIRST_LEVEL, "一级渠道"),
    TWO_LEVEL(ChannelRanKEnum.CHANNEL_TWO_LEVEL, "二级渠道");

    /**
     * 话务接入
     */
    public static final int CHANNEL_FIRST_LEVEL = 1;
    /**
     * H5
     */
    public static final int CHANNEL_TWO_LEVEL = 2;

    private Integer code;
    private String name;

    ChannelRanKEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ChannelRanKEnum of(Integer code) {
        if (code == null) {
            return null;
        }
        switch (code) {
            case 1:
                return FIRST_LEVEL;
            case 2:
                return TWO_LEVEL;
            default:
                return null;
        }
    }

    public static String getName(Integer code) {
        ChannelRanKEnum of = of(code);
        return of == null ? null : of.getName();
    }
}
